package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.ServletUtils;
import com.ruoyi.system.domain.HisOffice;
import com.ruoyi.system.mapper.HisOfficeMapper;
import com.ruoyi.system.mapper.SysPostMapper;
import com.ruoyi.system.service.IHisOfficeService;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class HisOfficeServiceImpl implements IHisOfficeService {

    @Autowired
    private HisOfficeMapper OfficeMapper;

    @Override
    public List<HisOffice> selectOfficeList(HisOffice office) {
        return OfficeMapper.selectOfficeList(office);
    }

    @Override
    public HisOffice queryOfficeById(Long deptId) {
        HisOffice hisOffice = OfficeMapper.queryOfficeById(deptId);
        List<HisOffice> list = OfficeMapper.queryHisOfficeClass();
        String[] deptNameList = {"急诊科", "内科", "外科", "眼科", "麻醉科"};
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
            if (list.get(i).getDeptCode().equals(hisOffice.getDeptCode())) {
                hisOffice.setDeptCodeMc(list.get(i).getDeptCodeMc());
            }
            // 设置deptNameMc名称
            if (hisOffice.getDeptCode().equals("0")) {
                hisOffice.setDeptNameMc("急诊科");
            } else {
                int a = Integer.parseInt(hisOffice.getDeptName());
                hisOffice.setDeptNameMc(deptNameList[a]);
            }
        }
        return hisOffice;
    }

    @Override
    public int insertOffice(HisOffice hisOffice) {
        return OfficeMapper.insertOffice(hisOffice);
    }

    @Override
    public int updateOffice(HisOffice hisOffice) {
        return OfficeMapper.updateOffice(hisOffice);
    }

    public int deleteOfficeByIds(Long[] ids) {
        return OfficeMapper.deleteOfficeByIds(ids);
    }

    public int susmedicalByIds(Long[] ids) {
        return OfficeMapper.susmedicalByIds(ids);
    }

    public int recmedicalByIds(Long[] ids) {
        return OfficeMapper.recmedicalByIds(ids);
    }
}
